<script lang="ts" context="module">
  import { sl3 } from "$lib/clients/sl3";
  import type Project from "$lib/models/project";
  import type { Load } from "@sveltejs/kit/types/internal";

  export const load: Load = async({params, fetch}) => {
    const scopeId = parseInt(params.scope.split("-")[0]);
    const projectId = parseInt(params.project.split("-")[0]);

    const project = await sl3(fetch).findProject(scopeId, projectId);

    return {
      stuff: { title: project.name },
      props: {project}
    };
	}
</script>

<script lang="ts">
  import ProjectEntry from "$lib/components/project/ProjectMain.svelte";
  import ProjectContext from "$lib/components/contexts/ProjectContext.svelte";
  import ItemCreateModal from "$lib/modals/ItemCreateModal.svelte";
  import RequirementCreateModal from "$lib/modals/RequirementCreateModal.svelte";
  import ItemAcquireModal from "$lib/modals/ItemAcquireModal.svelte";
  import DeletionModal from "$lib/modals/DeletionModal.svelte";
  import ProjectCreateEditModal from "$lib/modals/ProjectCreateEditModal.svelte";
  import MultiScheduleModal from "$lib/modals/MultiScheduleModal.svelte";

  export let project: Project;
</script>

<ProjectContext project={project}>
  <ProjectEntry />
  <ItemCreateModal />
  <ItemAcquireModal />
  <RequirementCreateModal />
  <DeletionModal />
  <ProjectCreateEditModal />
  <MultiScheduleModal />
</ProjectContext>